home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / src / niftp / ch_niftp.c next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  3.6 KB  |  140 lines

  1. #include "util.h"
  2. #include "mmdf.h"
  3.  
  4. /*
  5.  *     MULTI-CHANNEL MEMO DISTRIBUTION FACILITY  (MMDF)
  6.  *
  7.  *
  8.  *     Copyright (C) 1979,1980,1981  University of Delaware
  9.  *
  10.  *     Department of Electrical Engineering
  11.  *     University of Delaware
  12.  *     Newark, Delaware  19711
  13.  *
  14.  *     Phone:  (302) 738-1163
  15.  *
  16.  *
  17.  *     This program module was developed as part of the University
  18.  *     of Delaware's Multi-Channel Memo Distribution Facility (MMDF).
  19.  *
  20.  *     Acquisition, use, and distribution of this module and its listings
  21.  *     are subject restricted to the terms of a license agreement.
  22.  *     Documents describing systems using this module must cite its source.
  23.  *
  24.  *     The above statements must be retained with all copies of this
  25.  *     program and may not be removed without the consent of the
  26.  *     University of Delaware.
  27.  *
  28.  *
  29.  *     version  -1    David H. Crocker    March   1979
  30.  *     version   0    David H. Crocker    April   1980
  31.  *     version  v7    David H. Crocker    May     1981
  32.  *     version   1    David H. Crocker    October 1981
  33.  *
  34. /*
  35.  *      Modified by Steve Kille from ch_local  July 1982
  36.  *      Mar 83  Steve Kille     Upgrade for new mmdf
  37.  *
  38.  */
  39. #include <signal.h>
  40. #include "ch.h"
  41. #include "phs.h"
  42.  
  43. extern LLog *logptr;
  44. extern    Chan    *ch_nm2struct();
  45.  
  46. Chan    *chanptr;               /* Loaction for validating channel      */
  47. /*
  48.  *  CH_PNIFTP  --  Channel for transmission on NIFTP/ JNT mail
  49.  *
  50.  *  This channel produces a JNT Mail format file for each host
  51.  *  and then calls the NIFTP to transmit the file.
  52.  *
  53.  */
  54.  
  55. /*      MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN     */
  56.  
  57. main (argc, argv)
  58. int     argc;
  59. char   *argv[];
  60. {
  61.     extern char *dupfpath ();
  62.     short retval;
  63.  
  64.     mmdf_init (argv[0]);
  65.     siginit ();
  66.     signal (SIGINT, SIG_IGN);          /* always ignore interrupts         */
  67.  
  68.  
  69.  
  70.     if ((chanptr = ch_nm2struct (argv[0])) == (Chan *) NOTOK)
  71.     err_abrt (RP_PARM, "unknown channel name '%s'", argv[0]);
  72.                     /* find out who I am                  */
  73.                     /* NIFTP channel can have several     */
  74.                     /* names                              */
  75.  
  76.     retval = ch_niftp (argc, argv);
  77.     ll_close (logptr);              /* clean log end, if cycled  */
  78.     exit (retval);
  79. }
  80. /* **************  (ch_) NIFTP  MAIL DELIVERY  ************************ */
  81.  
  82. ch_niftp (argc, argv)             /* send to NIFTP channel               */
  83. int     argc;
  84. char   *argv[];
  85. {
  86.     ch_llinit (chanptr);
  87. #ifdef DEBUG
  88.     ll_log (logptr, LLOGBTR, "ch_niftp ()");
  89. #endif
  90.  
  91.     if (rp_isbad (qu_init (argc, argv)))
  92.     return (RP_NO);           /* problem setting-up for deliver     */
  93.     if (rp_isbad (pn_init ()))
  94.     return (RP_NO);
  95.  
  96.     phs_note (chanptr, PHS_CNSTRT);
  97.     phs_note (chanptr, PHS_CNGOT);
  98.  
  99.     if (rp_isbad (qu2pn_send (argv[0])))
  100.     return (RP_NO);           /* send the batch of outgoing mail    */
  101.  
  102.     qu_end (OK);                  /* done with Deliver function         */
  103.     pn_end (OK);
  104.  
  105.     phs_end (chanptr, RP_OK);
  106.  
  107.     return (RP_OK);               /* NORMAL RETURN                      */
  108. }
  109.  
  110. /* */
  111.  
  112. /* VARARGS2 */
  113.  
  114. err_abrt (code, fmt, b, c, d)     /* terminate ourself                  */
  115. short     code;
  116. char    fmt[],
  117.     b[],
  118.     c[],
  119.     d[];
  120. {
  121.     char linebuf[LINESIZE];
  122.  
  123.     qu_end (NOTOK);
  124.     pn_end (NOTOK);
  125.     if (rp_isbad (code))
  126.     {
  127. #ifdef DEBUG
  128.     if (rp_gbval (code) == RP_BNO || logptr -> ll_level >= LLOGBTR)
  129.     {                         /* don't worry about minor stuff      */
  130.         sprintf (linebuf, "%s%s", "[ABEND:  %s]\t", fmt);
  131.         ll_log (logptr, LLOGFAT, linebuf, rp_valstr (code), b, c, d);
  132.         abort ();
  133.     }
  134. #endif
  135.     }
  136.     ll_close (logptr);           /* in case of cycling, close neatly   */
  137.     exit (code);
  138. }
  139.  
  140.